﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ascx_Music : System.Web.UI.UserControl
{

    public int UserID = 0;

    public string musicPath = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        BindMusic();
    }

    public void BindMusic()
    {
        BLL.Music bll = new BLL.Music();
        string sql = string.Format(" UserID={0}and IsPass = 1  ", UserID);
        List<Model.Music> musics = bll.GetList(sql);
        if (musics == null || musics.Count == 0)
        {
            divMusic.Visible = false;
        }
        else
        {
            Random r = new Random();
            int next = r.Next(0, musics.Count);

            Model.Music m = musics[next];
            if (m != null)
            {
                musicPath = m.FilePath;
            }
            else
            {
                divMusic.Visible = false;
            }
        }
    }
}